﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.Reflection;
using Lilium.Collections;
using Microsoft.VisualStudio.TextTemplating;

namespace Lilium.Web.Mvc.T4
{
    public class T4ViewEngine : VirtualPathProviderViewEngine
    {
        public T4ViewEngine()
        {
            base.ViewLocationFormats = new string[] { "~/Views/{1}/{0}.tt", "~/Views/Shared/{0}.tt" };
            base.AreaViewLocationFormats = new string[] { "~/Areas/{2}/Views/{1}/{0}.tt", "~/Areas/{2}/Views/Shared/{0}.tt", };
            base.PartialViewLocationFormats = base.ViewLocationFormats;
            base.AreaPartialViewLocationFormats = base.AreaViewLocationFormats;
        }

        protected override IView CreatePartialView(ControllerContext controllerContext, string partialPath)
        {
            return new T4View(partialPath);
        }


        protected override IView CreateView(ControllerContext controllerContext, string viewPath, string masterPath)
        {
            return new T4View(viewPath);
        }
    }
}
